# 接下来将C文件编译为.so文件(windows下为DLL)。下面操作会生成adder.so文件
# gcc -shared -Wl,-install_name,adder.so -o adder.so -fPIC add.c

from ctypes import *

adder = CDLL('/Users/onlyone/open-github/p/python-example/com/c-language/adder.so')
result1 = adder.add_int(4, 2)
print("加法计算结果：" + str(result1))

a = c_float(1.3)
b = c_float(2.1)
add_float = adder.add_float
add_float.restype = c_float
print("Sum of 1.3 and 2.1 = ", add_float(a, b))
